<?php
    require_once(APPPATH . '/controllers/test/Toast.php');

    class Pictures_tests extends Toast
    {
        var $object_id = 11;

        function __construct()
        {
            parent::__construct(__FILE__);
            $this->load->helper('folder');
            $this->load->config('gallery');
            if(file_exists(APPPATH."libraries/object_gallery_lib.php")){
                $this->load->library("object_gallery_lib");
            }
            if(file_exists(APPPATH."models/settings_model.php")){
                $this->load->model("settings_model");
            }
        }

        public function create_thumbnails()
        {
            // get gallery folder
            $folder = $this->object_gallery_lib->find_gallery_column($this->object_id,'path');

            // get pictures names
            $pictures = array('desert.jpg','koala.jpg','tulips.jpg');

            // get thumbnail sizes from db
            $thumbnails_sizes = $this->settings_model->list_thumbnails(TRUE);

            // create thumbnails
            $this->load->library('pictures');
            $this->pictures->create_thumbnails($folder,$pictures,$thumbnails_sizes);

        }
        
        public function test_delete_picure()
        {
            
            $picture_id = 20;
            
            // get gallery folder
            $folder = $this->object_gallery_lib->find_gallery_column($this->object_id,'path');
            
            // get picture filename
            $this->load->library('pictures');
            $filename = $this->pictures->find_picture_column($picture_id,'filename');
            
            // get thumbnail sizes from db
            $thumbnails_sizes = $this->settings_model->list_thumbnails(TRUE);
            
            $this->firephp->log($folder);
            $this->firephp->log($filename);
            $this->firephp->log($thumbnails_sizes);
            
            // delete picture from pictures table
            $this->pictures->delete($picture_id);
            
            // delete picture from root gallery folder
            $this->pictures->delete_on_server($folder,$filename,$thumbnails_sizes);
        }
    }

?>